package com.example.rwq_test.webrtc.doubao;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @author: renwq
 * @date: 2025/10/17 10:31
 * @sesc: 自定义 WebSocket（信令） + Google STUN（NAT 辅助） + Kurento（媒体管道 & WebRTC 传输）
 */
@Configuration  // 替换 @Component
@EnableWebSocket  // 添加此注解启用 WebSocket
public class PlayerApp implements WebSocketConfigurer {
    @Bean
    public PlayerHandler handler() {
        return new PlayerHandler();
    }

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(handler(), "/player").setAllowedOrigins("*");
    }
}
